package Fuente;
import Comun.clsSaicFrame;
import java.sql.SQLException;
import javax.swing.ComboBoxModel;

public final class Donacion extends clsSaicFrame {
    int padre;
    public Donacion(int x)  {
         initComponents();
         //this.getGlassPane().setVisible(true);
         padre=x;
         iniciar();

    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        dataSource1 = new FuenteDeDatos.DataSource();
        panelRoundTranslucido2 = new Comun.PanelRoundTranslucido();
        jLabel1 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        buttonSeven1 = new org.edisoncor.gui.button.ButtonSeven();
        jTextField3 = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        dataTextField1 = new FuenteDeDatos.DataTextField();
        dataTextField2 = new FuenteDeDatos.DataTextField();
        dataTextField3 = new FuenteDeDatos.DataTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        dataTextField4 = new FuenteDeDatos.DataTextField();
        jLabel7 = new javax.swing.JLabel();
        jSpinner1 = new javax.swing.JSpinner();
        buttonSeven2 = new org.edisoncor.gui.button.ButtonSeven();
        dataLabel1 = new FuenteDeDatos.DataLabel();

        dataSource1.setCodigosql("select * from vw_donador");
        dataSource1.setDb("db_saic");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Donacion");

        jLabel1.setBackground(new java.awt.Color(255, 255, 255));
        jLabel1.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 30)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Recepción de Donaciones ");

        jTextField1.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 14));
        jTextField1.setEnabled(false);

        jLabel2.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 16));
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel2.setText("Numero de Donación:");

        jLabel3.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 16));
        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel3.setText("CURP:");

        jLabel4.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 16));
        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel4.setText("Fecha:");

        buttonSeven1.setText("Efectuar Recepción");
        buttonSeven1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonSeven1ActionPerformed(evt);
            }
        });

        jTextField3.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 14));
        jTextField3.setEnabled(false);
        jTextField3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField3ActionPerformed(evt);
            }
        });

        jLabel8.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 16));
        jLabel8.setForeground(new java.awt.Color(255, 255, 255));
        jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel8.setText("Tipo Sangre: ");

        dataTextField1.setCampo("Nombre");
        dataTextField1.setData(dataSource1);
        dataTextField1.setEnabled(false);
        dataTextField1.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 14));

        dataTextField2.setCampo("ApellidoM");
        dataTextField2.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
        dataTextField2.setData(dataSource1);
        dataTextField2.setEnabled(false);
        dataTextField2.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 14));

        dataTextField3.setCampo("ApellidoP");
        dataTextField3.setData(dataSource1);
        dataTextField3.setEnabled(false);
        dataTextField3.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 14));

        jLabel5.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 16));
        jLabel5.setForeground(new java.awt.Color(255, 255, 255));
        jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel5.setText("Nombre(s):");

        jLabel6.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 16));
        jLabel6.setForeground(new java.awt.Color(255, 255, 255));
        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel6.setText("Apellido(s):");

        dataTextField4.setCampo("Sangre");
        dataTextField4.setData(dataSource1);
        dataTextField4.setEnabled(false);
        dataTextField4.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 14));

        jLabel7.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 16));
        jLabel7.setForeground(new java.awt.Color(255, 255, 255));
        jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel7.setText("Cantidad:");

        jSpinner1.setModel(new javax.swing.SpinnerNumberModel(1, 1, 5, 1));
        jSpinner1.setValue(1);

        buttonSeven2.setText("Buscar");
        buttonSeven2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonSeven2ActionPerformed(evt);
            }
        });

        dataLabel1.setForeground(new java.awt.Color(255, 255, 255));
        dataLabel1.setCampo("CURP");
        dataLabel1.setData(dataSource1);
        dataLabel1.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 14));

        org.jdesktop.layout.GroupLayout panelRoundTranslucido2Layout = new org.jdesktop.layout.GroupLayout(panelRoundTranslucido2);
        panelRoundTranslucido2.setLayout(panelRoundTranslucido2Layout);
        panelRoundTranslucido2Layout.setHorizontalGroup(
            panelRoundTranslucido2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelRoundTranslucido2Layout.createSequentialGroup()
                .add(panelRoundTranslucido2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(panelRoundTranslucido2Layout.createSequentialGroup()
                        .add(38, 38, 38)
                        .add(panelRoundTranslucido2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 94, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(panelRoundTranslucido2Layout.createSequentialGroup()
                                .add(panelRoundTranslucido2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(jLabel5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 94, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(jLabel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 94, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 94, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                .add(30, 30, 30)
                                .add(panelRoundTranslucido2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                    .add(dataLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .add(dataTextField3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .add(dataTextField1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 293, Short.MAX_VALUE)
                                    .add(dataTextField2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .add(panelRoundTranslucido2Layout.createSequentialGroup()
                                        .add(jSpinner1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 71, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(20, 20, 20)
                                        .add(jLabel8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 129, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(dataTextField4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 71, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(29, 29, 29)))
                                .add(45, 45, 45)
                                .add(panelRoundTranslucido2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                    .add(buttonSeven2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .add(buttonSeven1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 158, Short.MAX_VALUE)))))
                    .add(panelRoundTranslucido2Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(panelRoundTranslucido2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, panelRoundTranslucido2Layout.createSequentialGroup()
                                .add(jLabel2)
                                .add(30, 30, 30)
                                .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 144, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(18, 18, 18)
                                .add(jLabel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 65, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(18, 18, 18)
                                .add(jTextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 286, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap())
        );
        panelRoundTranslucido2Layout.setVerticalGroup(
            panelRoundTranslucido2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelRoundTranslucido2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel1)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(panelRoundTranslucido2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 21, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jTextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 21, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(38, 38, 38)
                .add(panelRoundTranslucido2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 21, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(dataLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(buttonSeven2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(panelRoundTranslucido2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(panelRoundTranslucido2Layout.createSequentialGroup()
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(panelRoundTranslucido2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(dataTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 21, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(panelRoundTranslucido2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(dataTextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 21, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(dataTextField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(panelRoundTranslucido2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(panelRoundTranslucido2Layout.createSequentialGroup()
                                .add(17, 17, 17)
                                .add(jLabel7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 21, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                            .add(panelRoundTranslucido2Layout.createSequentialGroup()
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                                .add(panelRoundTranslucido2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                    .add(panelRoundTranslucido2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                        .add(jLabel8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 21, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(dataTextField4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                    .add(jSpinner1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))))
                    .add(panelRoundTranslucido2Layout.createSequentialGroup()
                        .add(15, 15, 15)
                        .add(buttonSeven1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(43, Short.MAX_VALUE))
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelRoundTranslucido2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelRoundTranslucido2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void buttonSeven1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSeven1ActionPerformed
      String resp=  this.dataSource1.ejecutarPA("call sp_aplicar_donacion('"+this.dataLabel1.getText()+"',"+this.padre+","+this.jSpinner1.getValue()+",@r);");
        new Error(this,true,resp,0,"¡ATENCION!").setVisible(true);
        if(resp.equals("Donación Correcta")){
             iniciar();
             this.dataTextField1.setText("");
             this.dataTextField2.setText("");
             this.dataTextField3.setText("");
             this.dataTextField4.setText("");
             this.dataLabel1.setText("");
             this.jSpinner1.setValue(1);
        }

    }//GEN-LAST:event_buttonSeven1ActionPerformed
public void iniciar(){
    try{

     this.jTextField3.setText(""+(this.dataSource1.consultaSN("select now()").getString(1)));
                //checar vista
           String folio= String.valueOf(this.dataSource1.consultaSN("select max(NoDonacion) from vw_donacion;").getDouble(1)+1);
           this.jTextField1.setText(folio);
        } catch (SQLException ex) {
           this.jTextField1.setText("1");
        }
}


    private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField3ActionPerformed

    private void buttonSeven2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSeven2ActionPerformed
       
            ComboBoxModel modelo = new javax.swing.DefaultComboBoxModel(new String[]{"CURP", "Nombre", "ApellidoP", "ApellidoM", "Direccion", "Telefono"});
            new busqueda(this, true, "vw_donador", modelo, this.dataSource1, "BUSQUEDA DE DONADORES","").activar();
           
      
    }//GEN-LAST:event_buttonSeven2ActionPerformed

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new Donacion(0).setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.edisoncor.gui.button.ButtonSeven buttonSeven1;
    private org.edisoncor.gui.button.ButtonSeven buttonSeven2;
    private FuenteDeDatos.DataLabel dataLabel1;
    private FuenteDeDatos.DataSource dataSource1;
    private FuenteDeDatos.DataTextField dataTextField1;
    private FuenteDeDatos.DataTextField dataTextField2;
    private FuenteDeDatos.DataTextField dataTextField3;
    private FuenteDeDatos.DataTextField dataTextField4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JSpinner jSpinner1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField3;
    private Comun.PanelRoundTranslucido panelRoundTranslucido2;
    // End of variables declaration//GEN-END:variables

}
